<template>
	<view>
		<view class="topSelect">
			<view class="topSelect-left">				
				
				<view  class="topSelect-item" @click="showPop('userName',lqrList)">
					<span class="nimilt">{{queryParams.userName?queryParams.userName:'申请人'}}</span>
					<u-icon name="arrow-down-fill" class="icon-tip" color="#999" size="10"></u-icon>
				</view>
			
				<view  class="topSelect-item" @click="showPop('status',statusList)">
					<span class="nimilt">{{queryParams.statusName?queryParams.statusName:'状态'}}</span>
					<u-icon name="arrow-down-fill" class="icon-tip" color="#999" size="10"></u-icon>
				</view>
				
			</view>
			<span class="search-reset" @click="reset">重置</span>
		</view>
		<u-datetime-picker :show="showinTime" :value="inTime" mode="date" closeOnClickOverlay @confirm="TimeConfirm"
			@cancel="TimeClose" @close="TimeClose"></u-datetime-picker>

		<u-action-sheet :show="isShowPop" :actions="actions" title="请选择" @close="isShowPop = false"
			@select="popSelect"></u-action-sheet>
	</view>


</template>

<script>
	import db from '@/common/localstorage.js'
	export default {
		
		data() {
			return {
				showinTime: false,
				inTime: Number(new Date()),
				timeType: '',
				queryParams: {
					userName:'',
					status:'',
					statusName:'',
				},

				isShowPop: false,
				popType: '',
				actions: [],
				
				
				lqrList:[],//申请人
				statusList:[{name:'待审核',id:0},{name:'通过',id:1},{name:'不通过',id:2}],
			}
		},
		mounted() {
			this.getDataList()
		},

		methods: {
			getDataList(){
				let that = this
				this.$postjson('/api/RqComplete/getSqr', {}).then(res => {
					let data = res.data.data
					data.forEach(v=>{
						v.id = v.userName
						v.name = v.userName
					})
					this.lqrList = data
				})
				
				
			},
			
			
		
			
			reset(){
				for (let key in this.queryParams) {
				  this.queryParams[key] = ''
				}
				this.onSearch()
			},
			
			showPop(type, list) {
				this.actions = list
				this.popType = type
				this.isShowPop = true
			},
			popSelect(e) {
				this.queryParams[this.popType] = e.id
				this.queryParams[this.popType+'Name'] = e.name
				this.onSearch()
			},
			
			onSearch(){
				this.$emit('onSearch',this.queryParams)
			},
			
			
			timeSelect(type) {
				this.timeType = type
				this.showinTime = true
			},

			TimeClose() {
				this.showinTime = false
			},
			TimeConfirm(e) {
				this.showinTime = false
				this.queryParams[this.timeType] =uni.$u.timeFormat(e.value, 'yyyy.mm.dd')
			},


		},

	}
</script>

<style lang="scss" scoped>
	.topSelect {
		// padding:8upx 0upx 28upx 0upx;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.topSelect-item {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #666666;
			display: flex;
			align-items: center;
			margin-right: 40upx;
		}

		.nimilt {
			display: inline-block;
			max-width: 120upx;
			overflow: hidden;
			white-space: nowrap;
		}

		.icon-tip {
			margin-top: 4upx;
			margin-left: 4upx;
		}

		.topSelect-item-icon {
			margin-left: 10upx;
			display: flex;
			flex-direction: column;
		}

		.topSelect-item-active {
			font-weight: 600;
			font-size: 32rpx;
			color: #111111;
		}
	}

	.topSelect-left {
		width: calc(100% - 120upx);
		display: flex;
		align-items: center;
		// justify-content: space-between;
	}

	.search-reset {
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #11AA66;
		margin-left: 60upx;
		width: 110rpx;
		height: 60rpx;
		background: rgba(17,170,102,0.1);
		border-radius: 10rpx;
		border: 2rpx solid #11AA66;
		line-height: 60upx;
		text-align: center;
	}
</style>